package CGLIB;

import lombok.Data;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author KiraYous
 * @version V1.0
 * @Package CGLIB
 * @date 2021/9/16 16:17
 * 使用枚举实现单例模式
 */
public enum MyMethodsInteceptor2 implements MethodInterceptor {
    INSTANCE;
    @Override
    public Object intercept(Object o, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {

        MyAspect myAspect=new MyAspect();
        myAspect.checkPermission();
//        method.invoke(o,)
        methodProxy.invokeSuper(o,args);
        myAspect.log();
        return null;
    }
}
